﻿/* WhatsApp Chat Widget Styles - Desktop Version (Complete) */
.whatsapp-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', 'Inter Fallback', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    background: #8B5CF6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

/* Chat tooltip */
.chat-toggle::before {
    content: attr(data-tooltip);
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: none;
}

.chat-toggle::after {
    content: '';
    position: absolute;
    right: 64px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: none;
}

.chat-toggle:hover::before,
.chat-toggle:hover::after {
    opacity: 1;
    visibility: visible;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.chat-toggle svg {
    color: white;
    width: 28px;
    height: 28px;
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

.chat-toggle.has-notification {
    animation: notificationGlow 1s ease-in-out;
}

.chat-toggle.has-new-messages {
    animation: newMessagePulse 2s ease-in-out;
}

@keyframes notificationGlow {
    0%, 100% { 
        box-shadow: 0 0 0 rgba(139, 92, 246, 0);
    }
    50% { 
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
    }
}

@keyframes newMessagePulse {
    0%, 100% { 
        box-shadow: 0 0 0 rgba(34, 197, 94, 0);
        transform: scale(1);
    }
    25% { 
        box-shadow: 0 0 15px rgba(34, 197, 94, 0.8);
        transform: scale(1.05);
    }
    50% { 
        box-shadow: 0 0 25px rgba(34, 197, 94, 0.6);
        transform: scale(1.1);
    }
    75% { 
        box-shadow: 0 0 15px rgba(34, 197, 94, 0.8);
        transform: scale(1.05);
    }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 420px;
    height: 520px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.whatsapp-chat-widget .chat-window.active {
    display: flex !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    animation: none !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: #8B5CF6;
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0f0f0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

/* Chat Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.status-dot.connecting {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#chatStatusText {
    font-size: 0.85em;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Online/Offline status styles */
.online-status {
    color: #10B981 !important;
    font-weight: 600;
}

.offline-status {
    color: #EF4444 !important;
    font-weight: 600;
}

/* Chat Close and Clear Buttons */
.chat-close, .chat-clear {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.chat-close:hover, .chat-clear:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-clear {
    font-size: 14px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    max-width: 95%;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.sent .message-content {
    background: #DCF8C6;
    max-width: 90%;
}

/* Make received (assistant) bubbles wider */
.message.received .message-content {
    max-width: 90%;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: block;
}

/* Chat Input */
.chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input input:focus {
    border-color: #8B5CF6;
}

.chat-input button {
    background: #8B5CF6;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-input button:hover {
    background: #7C3AED;
}

.chat-input button svg {
    color: white;
}

/* Typing indicator styles */
.typing-indicator {
    opacity: 0.7;
    animation: pulse 1.5s ease-in-out infinite;
}

.typing-indicator .message-content p {
    font-style: italic;
    color: #666;
}

/* Typing dots animation */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.message.received.real-reply .message-content {
    border-left: 3px solid #10B981;
}

.message.received.system-reply .message-content {
    border-left: 3px solid #9CA3AF;
}

.message-origin {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    line-height: 1;
    vertical-align: middle;
    background: #e5e7eb;
    color: #111827;
}

.message.received.real-reply .message-origin {
    background: rgba(16, 185, 129, 0.15);
    color: #065F46;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.message.received.system-reply .message-origin {
    background: rgba(156, 163, 175, 0.2);
    color: #374151;
    border: 1px solid rgba(156, 163, 175, 0.4);
}

.status-dot.offline + #chatStatusText {
    color: #ef4444;
}

/* Enhanced Chat Badge */
.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
    animation: badgePulse 2s infinite;
    transition: all 0.3s ease;
}

.chat-badge.hidden {
    display: none !important;
}

.chat-badge.animate {
    animation: badgeBounce 0.6s ease;
}

@keyframes badgePulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    }
}

@keyframes badgeBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Dark Theme Styles */
body.dark-theme .chat-window {
    background: #111827 !important;
    border: 1px solid #333333 !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3) !important;
}

body.dark-theme .chat-header {
    background: #2a2a2a !important;
    border-bottom: 1px solid #333333 !important;
}

body.dark-theme .chat-header h4 {
    color: #ffffff !important;
}

body.dark-theme .chat-header p {
    color: #888888 !important;
}

body.dark-theme .chat-messages {
    background: #111827 !important;
}

body.dark-theme .message {
    background: transparent !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
}

body.dark-theme .message.user {
    background: #8b5cf6 !important;
}

body.dark-theme .chat-input {
    background: #2a2a2a !important;
    border: 1px solid #333333 !important;
    color: #ffffff !important;
}

body.dark-theme .chat-input input {
    background: #2a2a2a !important;
    color: #ffffff !important;
}

body.dark-theme .chat-input input::placeholder {
    color: #888888 !important;
}

body.dark-theme .chat-input button {
    background: #8b5cf6 !important;
    color: #ffffff !important;
}

body.dark-theme .chat-input button:hover {
    background: #7c3aed !important;
}

body.dark-theme .chat-close {
    color: #ffffff !important;
}

/* Light Theme Styles */
body.light-theme .chat-window {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
}

body.light-theme .chat-header {
    background: #8b5cf6 !important;
    border-bottom: 1px solid #7c3aed !important;
}

body.light-theme .chat-header h4 {
    color: #ffffff !important;
}

body.light-theme .chat-header p {
    color: #ffffff !important;
}

body.light-theme .chat-messages {
    background: white !important;
}

body.light-theme .message {
    background: #f3f4f6 !important;
    color: #1f2937 !important;
    border: none !important;
}

body.light-theme .message.user {
    background: #8b5cf6 !important;
}

body.light-theme .chat-input {
    background: white !important;
    border: 1px solid #d1d5db !important;
    color: #1f2937 !important;
}

body.light-theme .chat-input input {
    background: white !important;
    color: #1f2937 !important;
}

body.light-theme .chat-input input::placeholder {
    color: #9ca3af !important;
}

body.light-theme .chat-input button {
    background: #8b5cf6 !important;
    color: #ffffff !important;
}

body.light-theme .chat-input button:hover {
    background: #7c3aed !important;
}

body.light-theme .chat-close {
    color: #ffffff !important;
}

/* Light theme status styles */
body.light-theme .online-status {
    color: #10B981 !important;
}

body.light-theme .offline-status {
    color: #EF4444 !important;
}

/* Dark theme status styles */
body.dark-theme .online-status {
    color: #10B981 !important;
}

body.dark-theme .offline-status {
    color: #EF4444 !important;
}

/* Hide scrollbar but keep functionality */
.whatsapp-chat-widget .chat-messages::-webkit-scrollbar {
    width: 6px;
}

.whatsapp-chat-widget .chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.whatsapp-chat-widget .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.whatsapp-chat-widget .chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .whatsapp-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-window {
        width: 360px;
        height: 520px;
        bottom: 75px;
    }
    
    .chat-toggle {
        width: 55px;
        height: 55px;
    }
    
    .chat-toggle svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 30px);
        right: 0px;
        height: 400px;
    }
}